package com.demo.utils;

/**
 * author:王蒙蒙
 * date创建日期:2025/8/1
 * 类注释说明:
 **/

import com.demo.utils.LogUtils;
import org.apache.logging.log4j.Logger;
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

public class RetryAnalyzer implements IRetryAnalyzer {
    private static final Logger log = LogUtils.getLogger();

    private int maxRetries = 3; // 最大重试次数
    private int retryCount = 0; // 当前重试次数

    @Override
    public boolean retry(ITestResult result) {
        if (retryCount < maxRetries) {
            retryCount++;
            log.info("失败了 进行重试... (" + retryCount + "/" + maxRetries + ")");
            return true; // 返回true表示需要重试
        }
        return false; // 返回false表示不再重试
    }
}

